package com.inwavetech.os.util;

import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.inwavetech.os.R;

/**
 * Created by jgskin on 1/26/14.
 */
public class LoaderAnimation {

    private final LayoutInflater layoutInflater;
    private final ViewGroup containerView;

    public LoaderAnimation(LayoutInflater inflater, ViewGroup view) {
        layoutInflater = inflater;
        containerView = view;
    }

    public void toggle() {
        ViewGroup loaderView = (ViewGroup) containerView.findViewById(R.id.loading_view_container);

        if (loaderView == null) {
            layoutInflater.inflate(R.layout.view_loader, containerView);
        } else {
            containerView.removeView(loaderView);
        }
    }

}
